package com.ycsj.goldmedalnewconcept.activity;

import cn.sharesdk.framework.Platform;
import cn.sharesdk.framework.Platform.ShareParams;
import cn.sharesdk.onekeyshare.OnekeyShare;
import cn.sharesdk.onekeyshare.ShareContentCustomizeCallback;
import cn.sharesdk.sina.weibo.SinaWeibo;

import com.mob.MobSDK;
import com.ycsj.goldmedalnewconcept.R;
import com.ycsj.goldmedalnewconcept.scoreReportActivity;
import com.ycsj.goldmedalnewconcept.utils.SPUtils;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;


//题库分享
public class ShareActivity extends Activity {
	
	private String[] split;
	private String[] times;
	private String[] marks;
	private String scoreInfo;
	
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_share);
		
		scoreInfo = getIntent().getStringExtra("scoreInfo");
		split = scoreInfo.split("&");
		 Log.e("share0", split[0]);
		 Log.e("share1", split[1]);
		 Log.e("share2", split[2]);
		 Log.e("share3", split[3]);
		times = split[2].split("=");
		marks = split[3].split("=");
		share();
	}

	private void share() {
		// TODO Auto-generated method stub
		
		MobSDK.init(ShareActivity.this, "12c24ea0b59b0",
				"aae63565fbd69b1acbfcdd0d5ac0b35c");
		OnekeyShare oks = new OnekeyShare();
		// 关闭sso授权
		oks.disableSSOWhenAuthorize();
		oks.setShareContentCustomizeCallback(new ShareContentCustomizeCallback() {

			@Override
			public void onShare(Platform platform, ShareParams paramsToShare) {
				// TODO Auto-generated method stub
				if (SinaWeibo.NAME.equals(platform.getName())) {
					paramsToShare.setTitle(getString(R.string.share));
					// titleUrl是标题的网络链接，仅在人人网和QQ空间使用
					String url = "http://m.moregolden.com:36356/scorePage.html?"
							+ split[0]
							+ "&"
							+ split[1]
							+ "&"
							+ split[2]
							+ "&"
							+ split[2]
							+ "&"
							+ split[3]
							+ "&exam_type=3";
					String title = SPUtils.getString(ShareActivity.this, "name")+"在题库环节花费" + times[1] + "秒正确率为"
							+ marks[1] + "%";

					paramsToShare
							.setTitleUrl("http://m.moregolden.com:36356/scorePage.html?"
									+ split[0]
									+ "&"
									+ split[1]
									+ "&"
									+ split[2]
									+ "&"
									+ split[2]
									+ "&"
									+ split[3] + "&exam_type=3");
					// paramsToShare.setTitle("今儿在题库环节花费"+Time+"秒正确率为"+Score+"%");
					// text是分享文本，所有平台都需要这个字段
					paramsToShare.setText(title + "\n\r想展现你的实力吗?来这里比拼一下吧！"
							+ url);
					// imagePath是图片的本地路径，Linked-In以外的平台都支持此参数
					// oks.setImagePath("/sdcard/test.jpg");//确保SDcard下面存在此张图片
					paramsToShare
							.setImageUrl("http://139.129.57.83:8080/Appandroid/applogo.png");
					// url仅在微信（包括好友和朋友圈）中使用
					paramsToShare
							.setUrl("http://m.moregolden.com:36356/scorePage.html?"
									+ split[0]
									+ "&"
									+ split[1]
									+ "&"
									+ split[2]
									+ "&"
									+ split[2]
									+ "&"
									+ split[3] + "&exam_type=3");
					// comment是我对这条分享的评论，仅在人人网和QQ空间使用
					paramsToShare.setComment("");
					// site是分享此内容的网站名称，仅在QQ空间使用
					paramsToShare.setSite(getString(R.string.app_name));
					// siteUrl是分享此内容的网站地址，仅在QQ空间使用
					paramsToShare
							.setSiteUrl("http://m.moregolden.com:36356/scorePage.html?"
									+ split[0]
									+ "&"
									+ split[1]
									+ "&"
									+ split[2]
									+ "&"
									+ split[2]
									+ "&"
									+ split[3] + "&exam_type=3");

				} else {
					paramsToShare.setShareType(Platform.SHARE_WEBPAGE);
					paramsToShare.setTitle(getString(R.string.share));
					// titleUrl是标题的网络链接，仅在人人网和QQ空间使用
					paramsToShare
							.setTitleUrl("http://m.moregolden.com:36356/scorePage.html?"
									+ split[0]
									+ "&"
									+ split[1]
									+ "&"
									+ split[2]
									+ "&"
									+ split[2]
									+ "&"
									+ split[3] + "&exam_type=3");
					paramsToShare.setTitle(SPUtils.getString(ShareActivity.this, "name")+"在题库环节花费" + times[1] + "秒正确率为"
							+ marks[1] + "%");
					// text是分享文本，所有平台都需要这个字段
					paramsToShare.setText("想展现你的实力吗?来这里比拼一下吧！");
					// imagePath是图片的本地路径，Linked-In以外的平台都支持此参数
					// oks.setImagePath("/sdcard/test.jpg");//确保SDcard下面存在此张图片
					paramsToShare
							.setImageUrl("http://139.129.57.83:8080/Appandroid/applogo.png");
					// url仅在微信（包括好友和朋友圈）中使用
					paramsToShare
							.setUrl("http://m.moregolden.com:36356/scorePage.html?"
									+ split[0]
									+ "&"
									+ split[1]
									+ "&"
									+ split[2]
									+ "&"
									+ split[2]
									+ "&"
									+ split[3] + "&exam_type=3");
					// comment是我对这条分享的评论，仅在人人网和QQ空间使用
					paramsToShare.setComment("");
					// site是分享此内容的网站名称，仅在QQ空间使用
					paramsToShare.setSite(getString(R.string.app_name));
					// siteUrl是分享此内容的网站地址，仅在QQ空间使用
					paramsToShare
							.setSiteUrl("http://m.moregolden.com:36356/scorePage.html?"
									+ split[0]
									+ "&"
									+ split[1]
									+ "&"
									+ split[2]
									+ "&"
									+ split[2]
									+ "&"
									+ split[3] + "&exam_type=3");

				}
			}
		});
		// 分享时Notification的图标和文字 2.5.9以后的版本不 调用此方法
		// oks.setNotification(R.drawable.ic_launcher,
		// getString(R.string.app_name));
		// title标题，印象笔记、邮箱、信息、微信、人人网和QQ空间使用

		// 启动分享GUI
		oks.show(getApplicationContext());
		
		
		finish();
	}
}
